(in-package :spring)

(defbean "testBean1" "dynaspring.TestBean1"
  :properties ("listProperty" (list "a" "b" "c")
	           "mapProperty" (map 1 "uno" 2 "due")))

(defbean "string1" "java.lang.String"
  :constructor-args ("string1"))
  
(defbean "testBean2" "dynaspring.TestBean1"
  :properties 
  ("listProperty"
   (list "a" (ref "string1")
	 (bean "java.lang.String" :constructor-args ("string2"))
	 (bean-field "testBean1" "listProperty"))
   "mapProperty"
   (map 1 (ref "string1")
	    2 (bean "java.lang.String" :constructor-args ("string2")))))
	 
(defbean "testBean2Merged" "dynaspring.TestBean1"
  :parent "testBean2"
  :properties ("listProperty" (merge (list "foo"))))
  
(defbean "testBean2NotMerged" "dynaspring.TestBean1"
  :parent "testBean2"
  :properties ("listProperty" (merge (list "foo") nil)))

;;deflist
(deflist "listBean1" ()
  (list 1 2)
  (list 3 4))

(deflist "listBean2" (:class "java.util.LinkedList")
  (list -1 0)
  (ref "listBean1")
  (list 5 6))

(deflist "listBean3" ()
  (ref "listBean1")
  (ref "listBean2"))

(deflist "listBean3" (:merge t)
  (list 7 8))

(deflist "listBean3" (:merge t)
  (list 9 10))

;;defset
(defset "setBean1" ()
  (set 1 2 3)
  (set 2 3 4))

(defset "setBean2" (:class "java.util.TreeSet")
  (set -1 0 1)
  (ref "setBean1")
  (set 4 5 6))

(defset "setBean3" ()
  (ref "setBean1")
  (ref "setBean2"))

(defset "setBean3" (:merge t)
  (list 6 7 8))

(defset "setBean3" (:merge t)
  (list 8 9 10))

;;defmap
(defmap "mapBean1" ()
  (map "a" 1 "b" 2)
  (map "a" 2 "c" 3))

(defmap "mapBean2" (:class "java.util.concurrent.ConcurrentHashMap")
  (map "z" -1 "k" 0)
  (ref "mapBean1")
  (map "c" 4 "d" 5 "e" 6))

(defmap "mapBean3" ()
  (ref "mapBean1")
  (ref "mapBean2"))

(defmap "mapBean3" (:merge t)
  (map "e" 7 "f" 8))

(defmap "mapBean3" (:merge t)
  (map "g" 9 "h" 10))
  
(defprops "propsBean1" ()
  (props "a" "b" "c" "d")
  (load-props (resource "classpath:dynaspring/testConfiguration.properties")))
  
(defprops "propsBean1" (:merge t)
  (props "c" "e" "d" "e"))